package com.gopay.bis.common.util;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.gopay.common.CustomHessianProxyFactory;
import com.gopay.common.constants.proccode.ProcCodeConstants;
import com.gopay.common.exception.GopayException;

public class RemoteServiceUtil {

    private static final Logger logger = LoggerFactory.getLogger(RemoteServiceUtil.class);
    
    public static Object getRemoteService(Class<?> clazz,String url) throws GopayException{
        logger.info("service:{}, url:{}", clazz.getName(), url);
        try {
            CustomHessianProxyFactory factory = new CustomHessianProxyFactory();
            factory.setConnectTimeOut(10000);
            factory.setReadTimeOut(20000);
            return factory.create(clazz, url);
        } catch (Exception e) {
            logger.error("调用远程服务异常", e);
            e.printStackTrace();
            throw new GopayException(ProcCodeConstants.PROC_CODE_100F3001, "调用远程服务异常");
        }
    }
}
